Map
The map provides a quick way to draw sprites, splicing images through sprite tiles, and each map tile is a sprite size of 8x8 pixels.
mget
mget(X, Y)
mset
mset(X, Y, VAL)
Query or set the data of map coordinates X and Y, if X and Y are out of bounds, the query returns 0.
Map data is a 16-bit integer, usually used to represent the index number of the sprite.
map
map(TILE_X, TILE_Y, [SX, SY], [TILE_W, TILE_H], [LAYERS])
At the screen area SX, SY position, start to draw the map, the map area start position is TILE_X, TILE_Y, width TILE_W, height TILE_H.
Example: Draw a 4x2 map tile to screen coordinates 20,20.
map(0, 0, 20, 20, 4, 2)
TILE_W / TILE_H defaults to the maximum map width and height.
Example: map() and camera() are used together to keep the sprite tiles always in the center of the screen.
camera(PL.X - __vm_width, PL.Y - __vm_height)
map()
LAYERS is the function defined by the bit. If there is this parameter, then only if the corresponding bit position of the sprite attribute data is valid, it will be drawn.
For example, LAYERS=0x5, then the sprite with the sprite data attribute bit0 or bit2 being 1 will be drawn.
Tile with sprite number 0 will not be drawn by default.
tline
tline(X0, Y0, X1, Y1, MX, MY, [MDX, MDY], [LAYERS])
Draw texture lines from X0, Y0 to X1, Y1, and the texture is sampled from the map. If the LAYERS parameter is valid, only the sprite data attributes that match will be sampled and drawn. (Same as map())
MX, MY are the starting points of the sampling of the corresponding map data, in units of tiles. The pixel data is collected from the 8x8 sprite image corresponding to the tiles.
Example:
2.0, 1.0 means starting from the upper left corner of the sprite corresponding to the map 2,1 position.
2.5, 1.5 means starting from the middle of the sprite (4,4).
MDX, MDY represent the incremental interval of mx, my during sampling, each time a pixel is drawn, mx, my will increase mdx, mdy. (default 0.125, 0, means that the x direction increases by one pixel, and the y direction remains unchanged)
Map coordinates (MX, MY) can be configured with a mask to cycle through.
Example: 8 block cycles in the horizontal direction and 4 block cycles in the vertical direction.
statctl('tlmw',8)
statctl('tlmh',4)
tline(...)
The default (0,0) means 256 block cycles.
It is also possible to set the starting offset of the tile:
statctl('tlmx',OFFSET_X)
statctl('tlmy',OFFSET_Y)
Like the map, the sprite with number 0 will not be sampled and drawn.